﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace RecipeBuildUnits
{
    public partial class frmSearchIngridient : Form
    {
        SqlCommand cmd;
        SqlDataAdapter da;
        DataSet ds;
        SqlCommandBuilder cmb;
        public frmSearchIngridient()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmSearchIngridient_Load(object sender, EventArgs e)
        {
            SqlConnection conn = Utils.getConnection();
            cmd = new SqlCommand("SELECT * FROM Ingridient", conn);
            conn.Open();
            da = new SqlDataAdapter(cmd);
            ds = new DataSet();
            da.Fill(ds, "Ingridient");
            cmb = new SqlCommandBuilder(da);
            dataGridView1.DataSource = ds.Tables[0];

            conn.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ds.Tables["Ingridient"].DefaultView.RowFilter = "IngName like \'%" + textBox1.Text + "%\'";
        }
    }
}
